
/** 定义全局数据类型
 */

#ifndef __GND_GLOBAL_H__
#define __GND_GLOBAL_H__

#include <string>
#include <iostream>
#include <glibmm/refptr.h>
#include <gdkmm/pixbuf.h>

namespace Gnodroid {

    /** 服务ID
     */
    enum ServiceId {
        SERVICE_CONNECTION = 0,
        SERVICE_INFOMATION,
        SERVICE_APPMANAGER,
        SERVICE_TASKMANAGER,
    
    };

    /** 模块ID
     */
    enum ModuleId {
        MODULE_CONNECTION = 0,
        MODULE_INFOMATION,
        MODULE_APPMANAGER,
        MODULE_TASKMANAGER,

    };


    //设备的型号和adb id用于连接
    class DeviceInfo
    {
    public:
        std::string model;  //设备显示名
        std::string id;     //设备ID
    };

    //设备的属性
    class DeviceProp
    {
    public:
        std::string model;
        std::string brand;
        std::string sdk;
        std::string android_ver;
        std::string kernel;
        //std::string abi;
        gint32 sc_width;
        gint32 sc_height;
        gint64 ram;
        gint64 rom;

        std::string toString()
        {
            return "MODEL: " + model + "\n" +
                    "BRAND: " + brand + "\n" +
                    "SDK: " + sdk + "\n" +
                    "ANVER: " + android_ver + "\n" +
                    "kernel: " + kernel + "\n" +
                    "W: " + std::to_string(sc_width) + "\n" +
                    "H: " + std::to_string(sc_height) + "\n" +
                    "RAM: " + std::to_string(ram) + "\n" +
                    "ROM: " + std::to_string(rom) + "\n";
        }
    };

    /** 安卓应用信息类
     */
    class AndroidApp
    {
    public:
        std::string label;                  //应用名
        std::string package;                //应用包
        std::string version;                //应用版本
        Glib::RefPtr<Gdk::Pixbuf> icon;     //应用图标
    };

    /** 显示调试信息
     * @param type
     * @param file
     * @param line
     * @param mes
     */
    inline void 
    log(std::string type, 
            std::string file, 
            int line, 
            std::string mes)
    {
        std::cout << type
                << " " 
                << file
                << " - "
                << line
                << " : "
                << mes
                << std::endl;
    }

    inline void 
    logNormal(std::string file,
            int line,
            std::string mes)
    {
        log("LOG", file, line, mes);
    }

    inline void 
    logWarn(std::string file,
            int line,
            std::string mes)
    {
        log("WARN", file, line, mes);
    }

    inline void 
    logError(std::string file,
            int line,
            std::string mes)
    {
        log("ERROR", file, line, mes);
    }

    #define __GND_DEBUG__

    #ifdef __GND_DEBUG__
        #define LOG(mes) (Gnodroid::logNormal(__FILE__, __LINE__, mes))
        #define LOG_WARN(mes) (Gnodroid::logWarn(__FILE__, __LINE__, mes))
        #define LOG_ERROR(mes) (Gnodroid::logError(__FILE__, __LINE__, mes))
    #else
        #define LOG(mes)
        #define LOG_WARN(mes)
        #define LOG_ERROR(mes)
    #endif

    //class App;
}


#endif
